package com.wlyuan.index.domain.index;

import com.wlyuan.core.domain.valueobj.OrderId;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author yuanjie
 */
@Getter
@AllArgsConstructor
public class OrderIndexScroll {
    private String scrollId;
    private Long total;
    private List<OrderIndex> orders;

    public Stream<OrderIndex> stream() {
        if (null == orders) {
            return Stream.empty();
        }
        return this.orders.stream();
    }

    public List<OrderId> getOrderIds() {
        return this.stream()
                .map(OrderIndex::getOrderId)
                .map(OrderId::new)
                .collect(Collectors.toList());
    }
}
